home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / CDDevice.mod < prev    next >
Text File  |  1995-06-29  |  16KB  |  370 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: CDDevice.mod $
  4.   Description: Interface to cd.device
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.7 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:13:14 $
  10.  
  11.   $VER: cd.h 1.11 (12.8.93)
  12.   Includes Release 40.15
  13.  
  14.   (C) Copyright 1992-1993 Commodore-Amiga, Inc.
  15.       All Rights Reserved
  16.  
  17.   Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
  18.   This file is part of the Oberon-A Interface.
  19.   See Oberon-A.doc for conditions of use and distribution.
  20.  
  21. *************************************************************************)
  22.  
  23. <* STANDARD- *>
  24.  
  25. MODULE [2] CDDevice;
  26.  
  27. IMPORT e := Exec;
  28.  
  29. (**************************************************************************
  30.  *                                                                        *
  31.  *   CD Commands                                                          *
  32.  *                                                                        *
  33.  **************************************************************************)
  34.  
  35. CONST
  36.  
  37.   reset *        = 1;
  38.   read *         = 2;
  39.   write *        = 3;
  40.   update *       = 4;
  41.   clear *        = 5;
  42.   stop *         = 6;
  43.   start *        = 7;
  44.   flush *        = 8;
  45.   motor *        = 9;
  46.   seek *         = 10;
  47.   format *       = 11;
  48.   remove *       = 12;
  49.   changeNum *    = 13;
  50.   changeState *  = 14;
  51.   protStatus *   = 15;
  52.  
  53.   getDriveType * = 18;
  54.   getNumTracks * = 19;
  55.   addChangeInt * = 20;
  56.   remChangeInt * = 21;
  57.   getGeometry *  = 22;
  58.   eject *        = 23;
  59.  
  60.  
  61.   info *         = 32;
  62.   config *       = 33;
  63.   tocMSF *       = 34;
  64.   tocLSN *       = 35;
  65.  
  66.   readXL *       = 36;
  67.  
  68.   playTrack *    = 37;
  69.   playMSF *      = 38;
  70.   playLSN *      = 39;
  71.   pause *        = 40;
  72.   search *       = 41;
  73.  
  74.   qCodeMSF *     = 42;
  75.   qCodeLSN *     = 43;
  76.   attenuate *    = 44;
  77.  
  78.   addFrameInt *  = 45;
  79.   remFrameInt *  = 46;
  80.  
  81.  
  82. (**************************************************************************
  83.  *                                                                        *
  84.  *   Device Driver Error Codes                                            *
  85.  *                                                                        *
  86.  **************************************************************************)
  87.  
  88. CONST
  89.  
  90.   errOpenFail *       = -1;  (* device/unit failed to open   *)
  91.   errAborted *        = -2;  (* request terminated early             *)
  92.   errNoCmd *          = -3;  (* command not supported by device      *)
  93.   errBadLength *      = -4;  (* invalid length (IO_LENGTH/IO_OFFSET) *)
  94.   errBadAddress *     = -5;  (* invalid address (IO_DATA misaligned) *)
  95.   errUnitBusy *       = -6;  (* device opens ok, but unit is busy    *)
  96.   errSelfTest *       = -7;  (* hardware failed self-test            *)
  97.  
  98.   errNotSpecified *   = 20;  (* general catchall                     *)
  99.   errNoSecHdr *       = 21;  (* couldn't even find a sector          *)
  100.   errBadSecPreamble * = 22;  (* sector looked wrong                  *)
  101.   errBadSecID *       = 23;  (* ditto                                *)
  102.   errBadHdrSum *      = 24;  (* header had incorrect checksum        *)
  103.   errBadSecSum *      = 25;  (* data had incorrect checksum          *)
  104.   errTooFewSecs *     = 26;  (* couldn't find enough sectors         *)
  105.   errBadSecHdr *      = 27;  (* another "sector looked wrong"        *)
  106.   errWriteProt *      = 28;  (* can't write to a protected disk      *)
  107.   errNoDisk *         = 29;  (* no disk in the drive                 *)
  108.   errSeekError *      = 30;  (* couldn't find track 0                *)
  109.   errNoMem *          = 31;  (* ran out of memory                    *)
  110.   errBadUnitNum *     = 32;  (* asked for a unit > NUMUNITS          *)
  111.   errBadDriveType *   = 33;  (* not a drive cd.device understands    *)
  112.   errDriveInUse *     = 34;  (* someone else allocated the drive     *)
  113.   errPostReset *      = 35;  (* user hit reset; awaiting doom        *)
  114.   errBadDataType *    = 36;  (* data on disk is wrong type   *)
  115.   errInvalidState *   = 37;  (* invalid cmd under current conditions *)
  116.  
  117.   errPhase *          = 42;  (* illegal or unexpected SCSI phase     *)
  118.   errNoBoard *        = 50;  (* open failed for non-existant board   *)
  119.  
  120.  
  121.  
  122. (**************************************************************************
  123.  *                                                                        *
  124.  * Configuration                                                          *
  125.  *                                                                        *
  126.  *       The drive is configured by TagList items defined as follows:     *
  127.  *                                                                        *
  128.  **************************************************************************)
  129.  
  130. CONST
  131.  
  132.   playSpeed *   = 00001H;
  133.   readSpeed *   = 00002H;
  134.   readXLSpeed * = 00003H;
  135.   sectorSize *  = 00004H;
  136.   xlECC *       = 00005H;
  137.   ejectReset *  = 00006H;
  138.  
  139.  
  140. (**************************************************************************
  141.  *                                                                        *
  142.  * Information                                                            *
  143.  *                                                                        *
  144.  *      Information/Status structure describes current speed settings     *
  145.  *      for read and play commands, sector size, audio attenuation        *
  146.  *      precision, and drive status.                                      *
  147.  *                                                                        *
  148.  **************************************************************************)
  149.  
  150. TYPE
  151.  
  152.   CDInfoPtr * = POINTER TO CDInfo;
  153.   CDInfo  * = RECORD        (*                                Default       *)
  154.     playSpeed *      : e.UWORD; (* Audio play speed       (75)              *)
  155.     readSpeed *      : e.UWORD; (* Data-rate of CD_READ command   (Max)     *)
  156.     readXLSpeed *    : e.UWORD; (* Data-rate of CD_READXL command (75)      *)
  157.     sectorSize *     : e.UWORD; (* Number of bytes per sector     (2048)    *)
  158.     xlECC *          : e.UWORD; (* CDXL ECC enabled/disabled                *)
  159.     ejectReset *     : e.UWORD; (* Reset on eject enabled/disabled          *)
  160.     reserved1 *      : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
  161.     maxSpeed *       : e.UWORD; (* Maximum speed drive can handle (75, 150) *)
  162.     audioPrecision * : e.UWORD; (* 0 = no attenuator, 1 = mute only,        *)
  163.                                 (* other = (# levels - 1)                   *)
  164.     status *         : e.UWORD; (* See flags below                          *)
  165.     reserved2 *      : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
  166.   END;
  167.  
  168. CONST
  169.  
  170. (* Flags for Status *)
  171.  
  172.   stsbClosed *    = 0;  (* Drive door is closed                        *)
  173.   stsbDisk *      = 1;  (* A disk has been detected                    *)
  174.   stsbSpin *      = 2;  (* Disk is spinning (motor is on)              *)
  175.   stsbTOC *       = 3;  (* Table of contents read.  Disk is valid.     *)
  176.   stsbCDRom *     = 4;  (* Track 1 contains CD-ROM data                *)
  177.   stsbPlaying *   = 5;  (* Audio is playing                            *)
  178.   stsbPaused *    = 6;  (* Pause mode (pauses on play command)         *)
  179.   stsbSearch *    = 7;  (* Search mode (Fast Forward/Fast Reverse)     *)
  180.   stsbDirection * = 8;  (* Search direction (0 = Forward, 1 = Reverse) *)
  181.  
  182. (* Modes for CD_SEARCH *)
  183.  
  184.   normal *   = 0;  (* Normal play at current play speed    *)
  185.   fFwd *     = 1;  (* Fast forward play (skip-play forward)*)
  186.   fRev *     = 2;  (* Fast reverse play (skip-play reverse)*)
  187.  
  188.  
  189. (**************************************************************************
  190.  *                                                                        *
  191.  * Position Information                                                   *
  192.  *                                                                        *
  193.  *      Position information can be described in two forms: MSF and LSN   *
  194.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  195.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  196.  *      The desired form is selected using the io_Flags field of the      *
  197.  *      IOStdReq structure.  The flags and the union are described        *
  198.  *      below.                                                            *
  199.  *                                                                        *
  200.  **************************************************************************)
  201.  
  202. TYPE
  203.  
  204.   RMSFPtr * = POINTER TO RMSF;
  205.   RMSF  * = RECORD
  206.     reserved * : SHORTINT;  (* Reserved (always zero) *)
  207.     minute *   : SHORTINT;  (* Minutes (0-72ish)      *)
  208.     second *   : SHORTINT;  (* Seconds (0-59)         *)
  209.     frame *    : SHORTINT;  (* Frame   (0-74)         *)
  210.   END;
  211.  
  212.   RLSNPtr * = POINTER TO RLSN;
  213.   RLSN  * = RECORD
  214.     lsn * : e.ULONG;       (* Logical Sector Number  *)
  215.   END;
  216.  
  217.  
  218. (**************************************************************************
  219.  *                                                                        *
  220.  * CD Transfer Lists                                                      *
  221.  *                                                                        *
  222.  *      A CDXL node is a double link node; however only single linkage    *
  223.  *      is used by the device driver.  If you wish to construct a         *
  224.  *      transfer list manually, it is only neccessary to define the       *
  225.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  226.  *      list functions by defining a List or MinList structure and by     *
  227.  *      using the AddHead/AddTail functions to create the list.  This     *
  228.  *      will create a double-linked list.  Although a double-linked       *
  229.  *      list is not required by the device driver, you may wish use it    *
  230.  *      for your own purposes.  Don't forget to initialize the            *
  231.  *      the List/MinList before using it!                                 *
  232.  *                                                                        *
  233.  **************************************************************************)
  234.  
  235. TYPE
  236.  
  237.   CDXLPtr * = POINTER TO CDXL;
  238.   CDXL  * = RECORD (e.MinNodeBase)
  239.     node *    : e.MinNode;     (* double linkage                  *)
  240.     buffer *  : e.APTR;        (* data destination (word aligned) *)
  241.     length *  : LONGINT;       (* must be even # bytes            *)
  242.     actual *  : LONGINT;       (* bytes transferred               *)
  243.     intData * : e.APTR;        (* interrupt server data segment   *)
  244.     IntCode * : e.PROC;        (* interrupt server code entry     *)
  245.   END;
  246.  
  247.  
  248. (**************************************************************************
  249.  *                                                                        *
  250.  * CD Table of Contents                                                   *
  251.  *                                                                        *
  252.  *      The CD_TOC command returns an array of CDTOC entries.             *
  253.  *      Entry zero contains summary information describing how many       *
  254.  *      tracks the disk has and the play-time of the disk.                *
  255.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  256.  *      information about the track.                                      *
  257.  *                                                                        *
  258.  **************************************************************************)
  259.  
  260. TYPE
  261.  
  262.   TOCSummary  * = RECORD END;
  263.   TOCSummaryPtr *= POINTER TO TOCSummary;
  264.  
  265.   TOCSummaryMSFPtr * = POINTER TO TOCSummaryMSF;
  266.   TOCSummaryMSF  * = RECORD (TOCSummary)
  267.     firstTrack * : SHORTINT; (* First track on disk (always 1)            *)
  268.     lastTrack *  : SHORTINT; (* Last track on disk                        *)
  269.     leadOut *    : RMSF;     (* Beginning of lead-out track (end of disk) *)
  270.   END;
  271.  
  272.   TOCSummaryLSNPtr * = POINTER TO TOCSummaryLSN;
  273.   TOCSummaryLSN  * = RECORD (TOCSummary)
  274.     firstTrack * : SHORTINT; (* First track on disk (always 1)            *)
  275.     lastTrack *  : SHORTINT; (* Last track on disk                        *)
  276.     leadOut *    : RLSN;     (* Beginning of lead-out track (end of disk) *)
  277.   END;
  278.  
  279.   TOCEntry  * = RECORD END;
  280.   TOCEntryPtr *= POINTER TO TOCEntry;
  281.  
  282.   TOCEntryMSFPtr * = POINTER TO TOCEntryMSF;
  283.   TOCEntryMSF  * = RECORD (TOCEntry)
  284.     ctlAdr *   : SHORTINT;     (* Q-Code info                  *)
  285.     track *    : SHORTINT;     (* Track number                 *)
  286.     position * : RMSF;         (* Start position of this track *)
  287.   END;
  288.  
  289.   TOCEntryLSNPtr * = POINTER TO TOCEntryLSN;
  290.   TOCEntryLSN  * = RECORD (TOCEntry)
  291.     ctlAdr *   : SHORTINT;     (* Q-Code info                  *)
  292.     track *    : SHORTINT;     (* Track number                 *)
  293.     position * : RLSN;         (* Start position of this track *)
  294.   END;
  295.  
  296.   CDTOC  * = RECORD END;
  297.   CDTOCPtr *= POINTER TO CDTOC;
  298.  
  299.   CDTOCMSFPtr * = POINTER TO CDTOCMSF;
  300.   CDTOCMSF  * = RECORD (CDTOC)
  301.     summary * : TOCSummaryMSF; (* First entry (0) is summary information *)
  302.     entry *   : ARRAY 256 OF TOCEntryMSF; (* Entries 1-N are track entries          *)
  303.   END;
  304.  
  305.   CDTOCLSNPtr * = POINTER TO CDTOCLSN;
  306.   CDTOCLSN  * = RECORD (CDTOC)
  307.     summary * : TOCSummaryLSN; (* First entry (0) is summary information *)
  308.     entry *   : ARRAY 256 OF TOCEntryLSN; (* Entries 1-N are track entries          *)
  309.   END;
  310.  
  311.  
  312. (**************************************************************************
  313.  *                                                                        *
  314.  * Q-Code Packets                                                         *
  315.  *                                                                        *
  316.  *      Q-Code packets are only returned when audio is playing.           *
  317.  *      Currently, only position packets are returned (ADR_POSITION)      *
  318.  *      The other ADR_ types are almost never encoded on the disk         *
  319.  *      and are of little use anyway.  To avoid making the QCode          *
  320.  *      structure a union, these other ADR_ structures are not defined.   *
  321.  *                                                                        *
  322.  **************************************************************************)
  323.  
  324. TYPE
  325.  
  326.   QCodeMSFPtr * = POINTER TO QCodeMSF;
  327.   QCodeMSF  * = RECORD
  328.     ctlAdr *        : SHORTINT; (* Data type / QCode type           *)
  329.     track *         : SHORTINT; (* Track number                     *)
  330.     index *         : SHORTINT; (* Track subindex number            *)
  331.     zero *          : SHORTINT; (* The "Zero" byte of Q-Code packet *)
  332.     trackPosition * : RMSF;     (* Position from start of track     *)
  333.     diskPosition *  : RMSF;     (* Position from start of disk      *)
  334.   END;
  335.  
  336.   QCodeLSNPtr * = POINTER TO QCodeLSN;
  337.   QCodeLSN  * = RECORD
  338.     ctlAdr *        : SHORTINT; (* Data type / QCode type           *)
  339.     track *         : SHORTINT; (* Track number                     *)
  340.     index *         : SHORTINT; (* Track subindex number            *)
  341.     zero *          : SHORTINT; (* The "Zero" byte of Q-Code packet *)
  342.     trackPosition * : RLSN;     (* Position from start of track     *)
  343.     diskPosition *  : RLSN;     (* Position from start of disk      *)
  344.   END;
  345.  
  346. CONST
  347.  
  348.   ctlAdrCtlMask * = 0F0H;  (* Control field *)
  349.  
  350.   ctlCtlMask *    = 0D0H;  (* To be ANDed with CtlAdr before compared  *)
  351.  
  352.   ctl2Aud *       = 000H;  (* 2 audio channels without preemphasis     *)
  353.   ctl2AudEmph *   = 010H;  (* 2 audio channels with preemphasis        *)
  354.   ctl4Aud *       = 080H;  (* 4 audio channels without preemphasis     *)
  355.   ctl4AudEmph *   = 090H;  (* 4 audio channels with preemphasis        *)
  356.   ctlData *       = 040H;  (* CD-ROM Data                              *)
  357.  
  358.   ctlCopyMask *   = 020H;  (* To be ANDed with CtlAdr before compared  *)
  359.  
  360.   ctlCopy *       = 020H;  (* When true, this audio/data can be copied *)
  361.  
  362.   ctlAdrAdrMask * = 00FH;  (* Address field                            *)
  363.  
  364.   adrPosition *   = 001H;  (* Q-Code is position information   *)
  365.   adrUPC *        = 002H;  (* Q-Code is UPC information (not used)     *)
  366.   adrISRC *       = 003H;  (* Q-Code is ISRC (not used)                *)
  367.   adrHybrid *     = 005H;  (* This disk is a hybrid disk               *)
  368.  
  369. END CDDevice.
  370.